package com.xunyin.modules.device.rest;


import com.xunyin.modules.aop.ForbidSubmit;
import com.xunyin.modules.device.domain.TDeviceVoiceSet;
import com.xunyin.modules.device.service.TDeviceVoiceSetService;
import com.xunyin.modules.device.service.dto.TDeviceQueryCriteria;
import com.xunyin.modules.log.Log;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author xunyinyunshang
 * 硬件语音提示内容设置
 * Created by xunyinyunshang <3594419785@qq.com>
 * CopyRight 讯音云商 https://www.tonetn.com
 * @date 2023-10-21
 */
@AllArgsConstructor
@Api(tags = "共享空间:硬件语音提示内容设置")
@RestController
@RequestMapping("api")
public class TDeviceVoiceSetController {

    private final TDeviceVoiceSetService tDeviceVoiceSetService;

    @Log("查询硬件语音提示内容设置")
    @ApiOperation("查询硬件语音提示内容设置")
    @GetMapping(value = "/tDeviceVoiceSet")
    public ResponseEntity getTDevicePowerSet(TDeviceQueryCriteria criteria, Pageable pageable) {

        Map<String, Object> queryAll = tDeviceVoiceSetService.queryAll(criteria, pageable);
        return new ResponseEntity<>(queryAll, HttpStatus.OK);
    }

    @ForbidSubmit
    @Log("新增硬件语音提示内容设置")
    @ApiOperation("新增硬件语音提示内容设置")
    @PostMapping(value = "/tDeviceVoiceSet")
    public ResponseEntity<Object> create(@Validated @RequestBody TDeviceVoiceSet resources) {

        return new ResponseEntity<>(tDeviceVoiceSetService.save(resources), HttpStatus.CREATED);
    }

    @ForbidSubmit
    @Log("修改硬件语音提示内容设置")
    @ApiOperation("修改硬件语音提示内容设置")
    @PutMapping(value = "/tDeviceVoiceSet")
    public ResponseEntity<Object> update(@Validated @RequestBody TDeviceVoiceSet resources) {
        tDeviceVoiceSetService.updateById(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }
}
